﻿using KC.ExtensionMethods;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace KC.Tests
{
	[TestClass()]
	public class GenericsTest
	{
		public TestContext TestContext { set; get; }

		[TestMethod()]
		[DeploymentItem("KC.ExtensionMethods.dll")]
		public void BuildInstanceListTest()
		{
			// Wanted to assert on each item's properties via a foreach, but I don't have access to a dynamic's properties from here. 
			// Even when I make it public. Go figure. What can ya do?

			List<string> inputs = new List<string>() { 
				"I am the very model of a modern Major-General;",
				"I've information animal, vegitable, and mineral.",
				"I know the Kings of England and i quote the fights historical,",
				"from Marathon to Waterloo, in order categorical." };
			List<dynamic> actual = Generics_Accessor.BuildInstanceList(inputs);
			Assert.AreEqual(string.Join(" ", inputs.ToArray()).ToLower().Split((new char[] { ' ', ',', ';', '\\', '/', ':', '\"', '\r', '\n', '.' })).Distinct().Count(), actual.Count);
		}
		[TestMethod()]
		[DeploymentItem("KC.ExtensionMethods.dll")]
		public void FilterByDuplicateWordsTest()
		{
			List<string>
				input = new List<string>() { 
				"Blargh test yawwwwn",
				"Blargh test yawwwwn" },
				expected = new List<string>() {
				"Blargh test yawwwwn"
				};
			List<string> actual = input.FilterByDuplicateWords(4);
			Assert.AreEqual(expected.Count, actual.Count);
			Assert.AreEqual(expected[0], actual[0]);	
		}
		[TestMethod()]
		[DeploymentItem("KC.ExtensionMethods.dll")]
		public void FilterByDuplicateWords2Test()
		{
			List<string>
				input = new List<string>() { 
				"Blargh test yawwwwn",
				"w00t" };
			List<string> actual = input.FilterByDuplicateWords(4);
			Assert.AreEqual(input.Count, actual.Count);
			for (int i=0; i < input.Count; i++)
				Assert.AreEqual(input[i], actual[i]);
		}
		[TestMethod()]
		[DeploymentItem("KC.ExtensionMethods.dll")]
		public void FilterByDuplicateWordsNullTest()
		{
			List<string>
				input = new List<string>() { };
			List<string> actual = input.FilterByDuplicateWords(4);
			Assert.AreEqual(input, actual);
		}
	}
}
